<?php
	class chucvudb
	{
		public function Add($QuyenHan, $TenChucVu)
		{
			$sql = "INSERT INTO `tbl_chucvu`(`QuyenHan`, `TenChucVu`) VALUES ($QuyenHan, '$TenChucVu')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaChucVu)
		{
			$sql = "DELETE FROM `tbl_chucvu` WHERE MaChucVu = $MaChucVu";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaChucVu, $QuyenHan, $TenChucVu)
		{
			$sql = "UPDATE `tbl_chucvu` 
					SET `QuyenHan`=$QuyenHan, 
						`TenChucVu` = '$TenChucVu'
					WHERE `MaChucVu` = $MaChucVu ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function GetList($MaChucVu, $QuyenHan, $TenChucVu)
		{
			$sql = "SELECT * FROM `tbl_chucvu` WHERE 1";
			if($MaChucVu != 0)
				$sql .= " AND MaChucVu = $MaChucVu";
			
			if($QuyenHan != "")
				$sql .= " AND QuyenHan = $QuyenHan ";
			
			if($TenChucVu != "")
				$sql .= " AND TenChucVu LIKE '%$TenChucVu%'";
				
			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
		public function checkGiamDoc()
		{
			$sql = " SELECT * FROM `tbl_chucvu` c WHERE c.MaChucVu =4 and c.MaChucVu in (SELECT MaChucVu FROM `tbl_nguoidung`) ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>